package edu.yzu.testspringboot002.config.wechat;

import lombok.RequiredArgsConstructor;

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration
public class WxMpServiceConfiguration {
    @Bean
    public WxMpDefaultConfigImpl wxMpDefaultConfig(){
        WxMpDefaultConfigImpl wxMpDefaultConfig=new WxMpDefaultConfigImpl();
        wxMpDefaultConfig.setAppId("wx4***c97f9b");
        wxMpDefaultConfig.setSecret("573****17e");
//        wxMpDefaultConfig.setToken("");
//        wxMpDefaultConfig.setAesKey("");
        return  wxMpDefaultConfig;
    }

    @Bean
    public WxMpService wxMpService() {
        WxMpService wxMpService =  new WxMpServiceImpl();
        wxMpService.setMaxRetryTimes(3);
        wxMpService.setWxMpConfigStorage(wxMpDefaultConfig());
        return wxMpService;
    }
}
